package cn.alex.sso.project.mapper;

import cn.alex.sso.project.entity.SysOperateLog;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
 * @author Alex
 * @description 针对表【sys_operat_log(操作日志表)】的数据库操作Mapper
 * @createDate 2024-10-22 14:02:48
 * @Entity generator.entity.SysOperatLog
 */
public interface SysOperatLogMapper extends BaseMapper<SysOperateLog> {

    default LambdaQueryWrapper<SysOperateLog> getQueryWrapper(SysOperateLog operateLog) {
        return new LambdaQueryWrapper<SysOperateLog>()
                .eq(ObjUtil.isNotEmpty(operateLog.getUserId()), SysOperateLog::getUserId, operateLog.getUserId())
                .like(StrUtil.isNotBlank(operateLog.getUsername()), SysOperateLog::getUsername, operateLog.getUsername())
                .like(StrUtil.isNotBlank(operateLog.getNickName()), SysOperateLog::getUsername, operateLog.getUsername())
                .like(StrUtil.isNotBlank(operateLog.getModule()), SysOperateLog::getModule, operateLog.getModule())
                .like(StrUtil.isNotBlank(operateLog.getAction()), SysOperateLog::getAction, operateLog.getAction())
                .like(StrUtil.isNotBlank(operateLog.getRequestUrl()), SysOperateLog::getRequestUrl, operateLog.getRequestUrl())
                .eq(ObjUtil.isNotEmpty(operateLog.getOperateTime()), SysOperateLog::getOperateTime, operateLog.getOperateTime())
                .orderByDesc(SysOperateLog::getOperateTime);
    }
}




